<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/12/4 0004
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
    <title>方法的调用</title>
</head>
<body>
<%@include file="checkLogin.jsp"%>

 <%!
     public int getAge(String idcard){
         //通过身份证获得年龄
         String year=idcard.substring(6,10);
         int birthday=Integer.parseInt(year);
         Calendar d=Calendar.getInstance();
         int now=d.get(Calendar.YEAR);
         return now-birthday;
     }
 %>
 <%
     String id="340123199204129023";
     int year1=getAge(id);
     out.print(id+",您今年："+year1+"岁了");
 %>
 <hr/>
 <%--
 <%
     String id2="340123199404129023";
     int year2=getAge(id2);
     out.print(id2+",您今年："+year2+"岁了");
 %>
 --%>
</body>
</html>
